package com.cheyun.netsalev3.view.dm.detail

import android.util.Log
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProviders
import com.cheyun.netsalev3.R
import com.cheyun.netsalev3.adapter.MyAdapter
import com.cheyun.netsalev3.databinding.FragmentDmHistoryRecordBinding
import com.cheyun.netsalev3.utils.BaseFragment
import com.cheyun.netsalev3.viewmodel.DmClueDetailsActivityViewModel

class DmHistoryRecordFragment : BaseFragment<FragmentDmHistoryRecordBinding>() {
    override fun initContentView(): Int {
        return R.layout.fragment_dm_history_record
    }

    override fun initViewModel(): ViewModel? {
        activity?.apply {
            return ViewModelProviders.of(this).get(DmClueDetailsActivityViewModel::class.java)
        }
        return null
    }


    private lateinit var adapter: MyAdapter

    override fun initView() {
        adapter = MyAdapter(R.layout.dm_historical_record_item, binding.viewModel)
        binding.recyclerView.adapter = adapter
    }

    override fun initData() {
        binding.viewModel?.recordsList?.observe(this, Observer { list ->
            adapter.submitList(list)
        })
    }

    override fun lazyInit() {
        Log.i(TAG,"override lazyinit")
    }

    companion object {
        fun newInstance() = DmHistoryRecordFragment()
    }

}
